package com.julyup.face.util;

import java.io.File;
import java.io.FileOutputStream;

/**
 * @Author: zhenzhong.wang@honeywell.com
 * @Date: 2019/3/22 3:17 PM
 */
public class FileUtils {
  /**
   * 将图片写入到磁盘
   * @param img 图片数据流
   * @param fileName 文件保存时的名称
   */
  public static void writeImageToDisk(byte[] img, String dir, String fileName) {
    File dirF = new File(dir);
    if (!dirF.exists()) {
      dirF.mkdir();
    }
    try {
      File file = new File(dir + "/" + fileName);
      FileOutputStream fops = new FileOutputStream(file);
      fops.write(img);
      fops.flush();
      fops.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
